﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Net;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Animation;
using System.Windows.Shapes;
using System.IO;

namespace G.APITest.Part
{
    public partial class AddFileChildWindow : ChildWindow
    {
        public AddFileChildWindow()
        {
            InitializeComponent();
        }

        private void OKButton_Click(object sender, RoutedEventArgs e)
        {
            fileInfo.ContentType = txtContentType.Text;
            fileInfo.FileName = txtFileName.Text;
            fileInfo.Name = System.IO.Path.GetFileNameWithoutExtension(fileInfo.FileName);
            this.DialogResult = true;
        }

        private void CancelButton_Click(object sender, RoutedEventArgs e)
        {
            this.DialogResult = false;
        }
        private G.SL.Net.FileInfo fileInfo = new G.SL.Net.FileInfo();
        public G.SL.Net.FileInfo FileInfo
        {
            get
            {
                return fileInfo;
            }
        }

        private void btnOpenFile_Click(object sender, RoutedEventArgs e)
        {
            OpenFileDialog open = new OpenFileDialog();
            if (open.ShowDialog() == true)
            {
                using (var file = open.File.OpenRead())
                {
                    fileInfo.FileBuffer = file.GetBytes();
                    txtFileName.Text = System.IO.Path.GetFileName(file.Name);
                }
            }
        }
    }
}

